#pragma once

#include <QObject>
#include "question.h"
#include <QRadioButton>
#include <QButtonGroup>

class SingleChoiceQuestin : public Question
{
    Q_OBJECT
public:
    struct Option {
        int id;
        QString code;
        QString content;
    };
    explicit SingleChoiceQuestin(QObject *parent = nullptr);

    // Question接口实现
    bool fromJson(const QJsonObject &json) override;
    QJsonObject toJson() const override;
    QWidget *createWidget(QWidget *parent = nullptr) override;
    //double calculateScore() const override;

    // 特有方法
    QList<Option> options() const { return m_options; }
    QString correctAnswer() const { return m_correctAnswer; }


private slots:
    void onOptionSelected(int id);

signals:
    void answerChanged();

private:
    QList<Option> m_options;
    QString m_correctAnswer;
    QString m_userAnswer; // 修改为QString类型，与基类保持一致
    QButtonGroup *m_buttonGroup = nullptr;

};
